<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />

    <title><spring:message code="jiesuan"></spring:message></title>
    <link href="${pageContext.request.contextPath }/phone/css/jiesuan.css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath }/phone/css/font/iconfont.css" rel="stylesheet" type="text/css">

</head>
<body>
    <div>
       
        <!--头部--有分类-->
        <div class="cate_header">
            <div class="putong_top">
                <a href="javascript:history.go(-1);"></a>
                <div><spring:message code="jiesuan"></spring:message></div>
            </div>
        </div>

        <div role="main" class="main" style="background:#F0F0F2;padding-bottom:0px;">
            <div class="address">
                <a href="javascript:void(0);">
                    <p id="addresss">
                        ${address.aName }  ${address.aPhone }<br/>
                      ${address.aAddress} ${address.aAddressInfo}
                    </p>
                </a>
            </div>
            <h4><spring:message code="dingdanmingxi"></spring:message></h4>
             <c:set  var="count" value="0"></c:set>
            <c:forEach items="${list}" var="item">
             <c:set var="count" value="${count+item.scTotalPrice }"></c:set>
                             
            <div class="order_xx">
            <c:choose>
			<c:when test="${item.scType==0}">
			<div class="te-ri"><spring:message code="member.myShoppingCart.printing"></spring:message></div> 
			</c:when>
			<c:when test="${item.scType==1}">
			<div class="te-ri"><spring:message code="member.myShoppingCart.buyout"></spring:message></div>
			</c:when>
			<c:when test="${item.scType==2}">
			<div class="te-ri"><spring:message code="member.myShoppingCart.endProduct"></spring:message></div>
			</c:when>
			<c:when test="${item.scType==3}">
			<div class="te-ri"><spring:message code="member.myShoppingCart.ml"></spring:message></div>
			</c:when>
			</c:choose> 
                
                <div class="order_con">
                <c:choose>
				<c:when test="${item.scType!=3}">
				<div class="order_img le" style="background-image:url(${item.scPatternImg});"></div>
                </c:when>
                <c:when test="${item.scType==3}">
                <div class="order_img le" style="background-image:url(${pageContext.request.contextPath }/upload/${item.fabricColor});"></div>
	            </c:when>
	            </c:choose>
                    
                    <div class="order_content le">
                        <div>
                        
                           <c:choose>
						<c:when test="${item.scType==0}">
						<div class="name_title le">
							<span class="bian"><spring:message code="huaxing"></spring:message>：${item.scPatternNo}</span><br>
							<span class="bian"${item.scNo}</span>
						</div>
                           
                                  
						</c:when>
						<c:when test="${item.scType==1}">
						<div class="name_title le">
							<span class="bian"><spring:message code="huaxing"></spring:message>：${item.scPatternNo}</span>
						</div>
						</c:when>
						<c:when test="${item.scType==2}">
						<div class="name_title le">
							<span class="bian"><spring:message code="huaxing"></spring:message>：${item.scPatternNo}</span><br>
							<span class="bian"><spring:message code="mianliao"></spring:message>：${item.scFabricNo}</span><br>
							<span class="bian">${item.scNo}</span>
						</div>
						</c:when>
						<c:when test="${item.scType==3}">
						<div class="name_title le">
							<span class="bian"><spring:message code="mianliao"></spring:message>：${item.scFabricNo}</span>
						</div>
						</c:when>
						</c:choose> 
                            
                            <span class="ri">X${item.scFabricSize}</span>
                            <div class="clr"></div>
                        </div>
                        <div class="jiage">￥${item.scPatternSinglePrice }</div>
                    </div>
                    <div class="clr"></div>
                </div>
                <div class="jine"><spring:message code="jinee"></spring:message>：￥${item.scTotalPrice }</div>
            </div>
            </c:forEach>
            
            <h4><spring:message code="kaijufapiao"></spring:message></h4>
            <div class="fapiao">
                <ul>
                    <li>
                        <input type="radio" name="fapiao" checked="checked" value="0" /><label><spring:message code="bukaifapiao"></spring:message></label>
                    </li>
                    <li>
                        <input type="radio" name="fapiao" value="1" /><label><spring:message code="putongfapiao"></spring:message></label>
                    </li>
                    <li class="fap hide">
                        <label><spring:message code="fapiaotaitou"></spring:message>：</label>
                        <input type="text" class="taitou" name="fapiaotaitou" />
                    </li>
                    <li class="fap hide">
                        <label><spring:message code="fapiaoneirong"></spring:message></label>
                    </li>
                </ul>
            </div>

            <div class="jiesuan">
                <span><spring:message code="heji"></spring:message>：￥${count}</span>
                <a  class="ri" href="javascript:jiesuan()"><spring:message code='qujiesuan'></spring:message></a>
                <div class="clr"></div>
            </div>


            <!--弹出浮动-->
            <div class="dizhi dizhilist hide">
                <div class="sel_addr">
                    <div class="addr_top">
                        <span class="le"><spring:message code="xuanzeshouhuodizhi"></spring:message></span>
                        <span class="ri close_addr">
                            <a href="#">
                                <i class="Hui-iconfont-close Hui-iconfont" style="font-size:24px;"></i>
                            </a>
                        </span>
                        <div class="clr"></div>
                    </div>
                    <ul class="h-180">
                    <c:forEach items="${addressdefault}" var="addressdefault">
                        <li >
                            <span class="addr_input le"><input id="${addressdefault.aId}" ${addressdefault.aDefault==1?'checked':'noenvelope'} type="radio" name="addr" /></span>
                            <span class="addr_con le" id="${addressdefault.aId}">
                               ${addressdefault.aName}  ${addressdefault.aPhone}<br/>
                                ${addressdefault.aAddress} ${addressdefault.aAddressInfo}
                            </span>
                            <div class="clr"></div>
                        </li>
                        </c:forEach>
                        
                    </ul>
                    <div class="addr_btn addr_shouhuo">
                        <a href="#"><spring:message code="tianjiashouhuodizhi"></spring:message></a>
                    </div>
                </div>
            </div>
			<!-- 新增地址 -->
			<form id="address" action="${pageContext.request.contextPath }/api/address/insertaddress">
			
			<div class="dizhi dizhinew hide">
                <div class="sel_addr">
                    <div class="addr_top">
                        <span class="le"><spring:message code="tianjiashouhuodizhi"></spring:message></span>
                        <span class="ri close_addr">
                            <a href="#">
                                <i class="Hui-iconfont-close Hui-iconfont" style="font-size:24px;"></i>
                            </a>
                        </span>
                        <div class="clr"></div>
                    </div>
                    <ul class="minelist pt-10 h-280">
				        <li class="bt-1"><div class="minelistleft"><spring:message code="reciveAddress.name"></spring:message>：</div><input class="minelistinput" type="text" name="aName" datatype="s2-30" nullmsg="<spring:message code='qingtianxiexinxi'></spring:message>" errormsg="<spring:message code='qingshurumingcheng'></spring:message>"/><div class="clearf"></div></li>
				        <li><div class="minelistleft"><spring:message code="reciveAddress.mobilePhoneNumber"></spring:message>：</div><input class="minelistinput" type="text" name="aPhone" datatype="m" nullmsg="<spring:message code='qingtianxiexinxi'></spring:message>" errormsg="<spring:message code='qingshuruzhengqueshoujihao'></spring:message>"/><div class="clearf"></div></li>
				        <li class="location-btn"><div class="minelistleft"><spring:message code="reciveAddress.localArea"></spring:message>：</div><input id="addressthis" name="aAddress" readonly="readonly" datatype="*" nullmsg="<spring:message code='qingxuanze'></spring:message>" class="minelistinput" type="text" /><i class="Hui-iconfont">&#xe63d;</i><div class="clearf"></div></li>
				        <li><div class="minelistleft"><spring:message code="reciveAddress.detailedAddress"></spring:message>：</div><input name="aAddressInfo" datatype="*" nullmsg="<spring:message code='qingtianxiexinxi'></spring:message>" placeholder="<spring:message code="reciveAddress.pleaseEnterDetailedAddress"></spring:message>" class="minelistinput" type="text" /><div class="clearf"></div></li>
				        <li><div class="minelistleft"><spring:message code="reciveAddress.zipCode"></spring:message>：</div><input name="aCode" datatype="p" nullmsg="<spring:message code='qingtianxiexinxi'></spring:message>" errormsg="<spring:message code='qingshuruzhengqueyoubian'></spring:message>" class="minelistinput" type="text" /><div class="clearf"></div></li>
				    </ul>
                    <div class="addr_btn">
                        <button type="submit"><spring:message code="reciveAddress.save"></spring:message></button>
                    </div>
                </div>
            </div>
            </form>
            <!-- 选择地址 -->
			<div class="dizhi dizhiselect hide">
                <div class="sel_addr">
                    <div class="addr_top">
                        <span class="le"><spring:message code="xuanzesuozaidi"></spring:message></span>
                        <span class="ri close_addr">
                            <a href="#">
                                <i class="Hui-iconfont-close Hui-iconfont" style="font-size:24px;"></i>
                            </a>
                        </span>
                        <div class="clr"></div>
                    </div>
                    <select name="province"></select><select name="city"></select><br>
                    <div class="addr_btn addressok">
                        <a href="JavaScript:void(0)"><spring:message code="reciveAddress.save"></spring:message></a>
                    </div>
                </div>
            </div>
	        </div>
	        </div>
      <form id="mai"  target="_top"   action="${pageContext.request.contextPath }/api/orders/caraccount" method="post">
        <input type="hidden" name="oId" id="oId" value="${fn:join(oId,',')}">
        </form>
        <form id="jiesuan">
        <input type="hidden" name="oId" id="oId" value="${fn:join(oId,',')}" autocomplete="off">
        <input type="hidden" name="addId" id="addId" value="${address!=null?address.aId:''}" autocomplete="off">
        <input type="hidden" name="taitou" id="taitou" autocomplete="off">
        <input type="hidden" name="instate" id="instate"  autocomplete="off">
        </form>
    <script src="${pageContext.request.contextPath }/phone/js/jquery-1.8.3.min.js"></script>
    <script src="${pageContext.request.contextPath }/phone/js/extra.js"></script>
    <!--提示信息-->
 <script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/layer_mobile/layer.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/Validform/5.3.2/Validform.min.js"></script>

<c:if test="${language=='en'}">
<!-- 修改所在地选择地区 -->
<script language="javascript" src="${pageContext.request.contextPath }/phone/js/PCASClass.js"></script>
</c:if>
<c:if test="${language=='zh_cn'}">
<!-- 修改所在地选择地区 -->
<script language="javascript" src="${pageContext.request.contextPath }/phone/js/PCASClass.js"></script>
</c:if>
<!-- 选择所在地 -->
<script language="javascript">
//结算验证发票抬头是否为空
function jiesuan(){
	$("input[name=fapiao]").each(function(){
		if($(this).attr("checked") == "checked"){
			if($(this).val()==1){
				if($("input[name=fapiaotaitou]").val() ==""){
					layer.open({content: '<spring:message code="qingtianxiefapiaotaitou"></spring:message>',skin: 'msg',time: 1});
				   	
					return;
				}else{
					$("#taitou").val($(".taitou").val());
					$("#instate").val(1);
				}
			}else{
				$("#taitou").val("");
				$("#instate").val("0");
			}
		}
	});
	if($("#addId").val()==""){
		layer.open({content: '<spring:message code="qingxuanzeshouhuodizhi"></spring:message>',skin: 'msg',time: 1});
	   		
		return;
	}
	
	 $.ajax({
		 url:'${pageContext.request.contextPath }/web/orders/ordergenerated',
		 async : false,
		 data: $("#jiesuan").serialize(),
		 type : "POST", 
		 success :function(result){
		 var status=result.msg.status;
		 var desc=result.msg.desc;
		 if(status == 0){
			 layer.open({content: '<spring:message code="xiadanchenggong"></spring:message>',skin: 'msg',time: 1});
	   	   		
			 setTimeout(function(){location.href="${pageContext.request.contextPath }/api/orders/orderslist";},2000);
				
				
			
		 }else if(status ==1){//失败有花型失效
			 layer.open({content: '<spring:message code="youhuaxingbeimaiduanxiadanshibai"></spring:message>',skin: 'msg',time: 1});
	   	   		
		    }
		 }
		 });
	
}

//选择地址
$("input[name=addr]").click(function(){
	$("#addresss").html($("span[id="+$(this).attr("id")+"]").html());
	
	$("#addId").val($(this).attr("id"));
	
	setTimeout(function(){
		$(".dizhi").addClass("hide")
	},1000);
	
	
});


    new PCAS("province", "city");
    $(function(){
    	$.Tipmsg.r=null;
    	var showmsg=function(msg){
    		if(msg=="正在提交数据…"){
    			return;
    		}
    		 layer.open({content: msg,skin: 'msg',time: 1});
	   	   		
    	}
    	$("#address").Validform({
    		ajaxPost:true,
    		tiptype:function(msg){
    			showmsg(msg);
    		},
    		tipSweep:true,
    		callback:function(result){
    			 var status=result.msg.status;
    			 var desc=result.msg.desc;
    			 if(status == 0){
    				 layer.open({content: '<spring:message code="baocunchenggong"></spring:message>',skin: 'msg',time: 1});
    		   	   		
    				parent.$("#mai").submit();
    				}else if(status == 3){//只能添加3条记录
    					layer.open({content: '<spring:message code="zhinengtianjia3tiaojilu"></spring:message>',skin: 'msg',time: 1});
    		   	   		
    			 }else if(status == 2){//没登录
    				 layer.open({content: '<spring:message code="weidenglu"></spring:message>',skin: 'msg',time: 1});
    		   	   		
    			    }else if(status ==1){//失败
    			    	layer.open({content: '<spring:message code="caozuoshibai"></spring:message>',skin: 'msg',time: 1});
    		   	   		
    			    }
    			 }
    	});
    });
</script>

</body>
</html>
